<template>
    <div class="content">
        <login v-if="openLogin" @closeLogin="loginMethod"/>
      <!--  导航栏    -->
      <div class="content-top">
        <div class="header">
          <div class="header-left">
            <!-- logo  -->
            <img src="@/assets/img/index.png" alt="logo">
            <span>胖胖龙Study</span>
          </div>
          <div class="header-right">
            <div class="router">
              <span>首页</span>
              <span>题库</span>
              <span>宠物</span>
              <span @click="test">测试</span>
            </div>
            <div class="icon-list">
              <i class="iconfont icon-sousuo rotate"></i>
              <i style="width: 0.3rem"></i>
              <i class="iconfont icon-cuotiben3 rotate"></i>
            </div>
                <div class="login"
                      :style="{backgroundColor: loginBK}"
                >
                  <transition name="success-login">
                    <div class="user" v-if="successLogin">
                      <img src="@/assets/img/long1.png" alt="头像">
                      <div class="nameplate">Lv: 6</div>
                    </div>
                  </transition>
                  <transition name="cut-login">
                  <div v-if="cutLoginStatus"
                        class="login-item"
                        @click="loginMethod"
                  >
                    <i class="iconfont icon-yuanzi rotate"></i>
                    <div>登录</div>
                  </div>
              </transition>
                </div>

          </div>
        </div>
        <!--   欢迎语     -->
        <div class="writer-info">
          <span>欢迎Study🎉</span>
          <div class="outside">
            <a-popover placement="bottomLeft">
              <template #content>
                <img src="@/assets/img/gzh.jpg" alt="公众号" style="height: 200px;width: 200px">
              </template>
              <div class="outside-body">
                <i class="iconfont icon-gongzhonghao rotate"></i>
                <span>公众号</span>
              </div>
            </a-popover>
            <a-popover placement="bottomLeft">
              <template #content>
                <img src="@/assets/img/gitee.png" alt="Gitee" style="height: 4rem;width: 4rem;padding: 0.3rem">
              </template>
            <div class="outside-body">
              <i class="iconfont icon-gitee-2 rotate"></i>
              <span>Gitee</span>
            </div>
            </a-popover>
            <a-popover placement="bottomLeft">
              <template #content>
                1531290769@qq.com
              </template>
            <div class="outside-body">
              <i class="iconfont icon-youxiang rotate"></i>
              <span>Email</span>
            </div>
            </a-popover>
          </div>
        </div>
        <!-- 说明  -->
        <div class="explain">
          欢迎大家使用,随着学习的时间增长,还会获得独特的等级铭牌哦~
        </div>
        <!--  卡片     -->
        <div class="card-list">
          <div class="card">
            <img src="@/assets/img/long1.png" alt="图片加载失败">
            <span>我们将提供多样化的题库供大家学习~</span>
          </div>
          <div class="card">
            <img src="@/assets/img/long2.png" alt="图片加载失败">
            <span>祝大家学有所成!</span>
          </div>
          <div class="card">
            <img src="@/assets/img/long3.png" alt="图片加载失败">
            <span>大家可以多提供题目。</span>
          </div>
        </div>
      </div>
      <!--  题型列表    -->
      <div class="content-body">
        <div class="fgx">
          <img src="@/assets/img/wwl.png" alt="">
          <div class="list-title">题库</div>
        </div>
        <div class="class-list">
              <div class="item" v-for="item in conurseClassTree" :key="item.id">
                <div class="item-left">
                  <!--  图标  -->
                  <i :class="item.icon.toString()"></i>
                  <span>{{item.name}}</span>
                </div>
                <div class="item-right">
                  <div class="itme-router" v-for="item2 in item.children" :key="item.id">
                    <img src="@/assets/icon/topicList/java.png" >
                    <span>{{item2.name}}</span>
                  </div>
                </div>
              </div>
        </div>
      </div>
      <BottomDescription />
    </div>
</template>

<script setup lang="ts">
import BottomDescription from "@/components/bottomDescription.vue";
import {queryConurseClassifyTree} from "@/api/conurseClassify.ts";
import {ref} from "vue";
import Login from "@/components/login.vue";

let openLogin = ref<Boolean>(false);
let conurseClassTree = ref<ConurseClassifyTreeType[]>()
let cutLoginStatus = ref<Boolean>(true)
let loginBK = ref('#963CFEFF')
let successLogin = ref<Boolean>(false)
const test = () => {
  if (cutLoginStatus.value === true) {
    cutLoginStatus.value = false
    loginBK.value = "#ffffff"
    setTimeout(()=>{
      successLogin.value = true
    }, 500)
  }else {
    successLogin.value = false
    loginBK.value = "#963CFEFF"
    setTimeout(()=> {
      cutLoginStatus.value = true
    }, 400)
  }



}
const init = async () => {
  let {data: {data}} = await queryConurseClassifyTree()
  conurseClassTree.value = data
}
// 登录方法
const loginMethod = async () => {
  openLogin.value = !openLogin.value;
  if (openLogin.value) {
    document.body.style.overflow = 'hidden';
  }else {
    document.body.style.overflow = 'auto';
  }

}
init()
</script>

<style lang="less" scoped>
  .content-top {
    height: 10rem;
    padding: 0.32rem 0 1rem 0;

    .header {
      display: flex;
      flex-direction: row;
      width: 90%;
      height: 1.6rem;
      margin: 0 auto;
      padding: 0 0.32rem 0 0.32rem;
      border-radius: .3rem;
      background-color: #ffffff;

      .header-left {
        height: 100%;
        display: flex;
        flex: 1;
        align-items: center;

        img {
          height: 1rem;
          width: 1rem;
        }

        span {
          font-size: .42rem;
          font-weight: bold;
          color: #595959;
          margin-left: 0.2rem;
        }
      }

      .header-right {
        height: 100%;
        display: flex;
        align-items: center;

        .router {
          height: 0.48rem;
          display: flex;
          align-items: center;
          color: #595959;
          font-size: .34rem;
          font-weight: bold;
          padding: 0 0.2rem;
          border-left: 1px solid #dfdfdf;

          span {
            padding: 0 0.2rem;
          }
        }

        .icon-list {
          display: flex;
          height: 0.48rem;
          align-items: center;
          padding: 0 0.3rem 0 0.3rem;
          border-right: 1px solid #dfdfdf;
          border-left: 1px solid #dfdfdf;

          i {
            font-size: 0.44rem;
            color: #595959;
          }
        }

        .login {
          width: 1.76rem;
          height: 0.72rem;
          //background-color: hsl(267.84deg 98.98% 61.57%);
          color: rgb(255 255 255 / 1);
          border-radius: 0.15rem;
          margin-left: 0.4rem;
          transition: all .1s;

          .login-item {
            margin: 0;
            height: 100%;
            display: flex;
            align-items: center;
            justify-content: space-between;


            i {
              font-size: .4rem;
              margin-left: .2rem;
            }
            div{
              font-size: 0.4rem;
              font-weight: 550;
              line-height: 0.72rem;
              margin-right: 0.2rem;
            }
          }

          .user {
            display: flex;
            align-items: center;
            justify-content: space-between;

            img {
              height: .8rem;
              width: .8rem;
              border-radius: 50%;
              border: 1px solid #b8b8b8;
              box-shadow: 0.02rem 0.02rem 0.1rem rgba(104, 104, 104, 0.5);
            }

            .nameplate {
              width: .9rem;
              font-size: 0.3rem;
              background-image: linear-gradient(to right, #00e8ff, #93fcff, #f999fb);
              border-radius: 0.2rem;
              color: #f8f7f7;
              padding: 0.04rem;
              box-shadow: 0.03rem 0.02rem 0.1rem rgba(120, 120, 120, 0.5);
              font-weight: bold;
            }

          }
          .login-item:hover {
            cursor: pointer;
          }

          .login-item:hover > i {
            animation: spin 2s linear infinite;
          }

          @keyframes spin {
            from {
              transform: rotate(0deg);
            }
            to {
              transform: rotate(360deg);
            }
          }
        }
      }
    }

    .writer-info {
      display: flex;
      flex-direction: row;
      align-items: center;
      width: 80%;
      margin: .7rem auto .27rem auto;

      span {
        font-size: 1.3rem;
        font-weight: 550;
        color: rgb(255 255 255 / 1);
      }

      .outside {
        display: flex;
        .outside-body {
          width: 1.88rem;
          height: 0.48rem;
          display: flex;
          align-items: center;
          justify-content: center;
          border-radius: 0.2rem;
          margin-left: 0.3rem;

          span {
            font-size: .3rem;
            padding: 0 0.1rem;
          }

          i {
            font-size: .3rem;
            color: rgb(255 255 255 / 1);
          }
        }

        .outside-body:hover {
          box-shadow: 0.13rem 0.13rem 0.13rem rgba(104, 104, 104, 0.5);
          transition: box-shadow 0.5s;
        }

        .outside-body:nth-child(1) {
          background-color: #676aff;
        }
        .outside-body:nth-child(2) {
          background-color: #46d1ec;
        }
        .outside-body:nth-child(3) {
          background-color: #2e9cea;
        }
        .outside-body:hover {
          cursor: pointer;
        }
      }
    }

    .explain {
      width: 80%;
      margin: 0 auto;
      font-size: .36rem;
      color: #717171;
    }

    .card-list {
      width: 80%;
      margin: 1rem  auto;
      display: flex;

      .card {
        display: flex;
        align-items: center;
        padding: 0 0.3rem;
        width: 4rem;
        height: 2rem;
        border: 1px solid #dfdfdf;
        background-color: #ffffff;
        border-radius: 0.3rem;
        box-shadow: 0.13rem 0.13rem 0.13rem rgba(104, 104, 104, 0.5);

        img {
          height: 1.3rem;
          width: 1.3rem;
          border-radius: 50%;
          border: 1px solid #e1e1e1;
        }

        span {
          font-size: 0.3rem;
          color: #717171;
          margin-left: 0.2rem;
        }
      }

      .card:hover {
        cursor: pointer;
        transform: translate(0.1rem, -0.1rem);
        transition: transform .7s;
      }

      .card:nth-child(2) , .card:nth-child(3) {
        margin-left: 0.3rem;
      }
    }
  }
  .content-top::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 13rem;
    z-index: -1;
    background: url("@/assets/img/bj.jpg") no-repeat center fixed;
    background-size: cover;
    filter: blur(0.4rem);
  }

  .content-body {
    width: 100%;
    border-top-left-radius: 0.7rem;
    border-top-right-radius: 0.7rem;
    background-color: rgb(245 245 245/ 1);
    .fgx {
      display: flex;
      align-items: center;
      width: 90%;
      height: 1.4rem;
      margin: 0 auto 0.5rem auto;
      border-bottom: 1px solid rgb(227, 227, 227);

      img {
        height: .8rem;
        width: .8rem;
      }

      .list-title {
        font-size: 0.4rem;
        color: #515151;
        font-weight: bold;
        margin-left: 0.1rem;
      }
    }

    .class-list {
      width: 90%;
      margin: 0 auto;

        .item {
          height: 2.4rem;
          display: flex;
          box-sizing: initial;
          padding-bottom: 0.8rem;
          border-bottom: 1px solid rgb(227, 227, 227);

          .item-left {
            width: 1.6rem;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            box-sizing: border-box;

            span {
              font-size: .28rem;
              color: #2b2b2b;
            }
            i {
              font-size: .8rem;
              color: #2b2b2b;
            }
          }
          .item-left:hover > span  {
              color: #676aff;
          }
          .item-left:hover > i  {
            color: #676aff;
          }

          .item-right {
            display: flex;
            align-items: center;
            overflow-x: auto;

            .itme-router {
              flex: 1;
              display: flex;
              flex-direction: column;
              align-items: center;
              justify-content: center;
              width: 1.8rem;
              margin-left: 0.6rem;

              img {
                height: 1.5rem;
                width: 1.5rem;
                border-radius: 0.2rem;
                border: 1px solid #dddddd;
                flex: 1;
              }
              span {
                margin-top: 0.1rem;
                font-size: 0.28rem;
                font-weight: bold;
                color: #4a4a4a;
              }
            }

            .itme-router:hover > img  {
              transform: scale(1.1);
              transition: all .3s;
              border-color: #9a9bff;
            }

            .itme-router:hover {
              cursor: pointer;
            }
          }

          .item-right::-webkit-scrollbar {
            height: 0.22rem; /* 滚动条的宽度 */
          }
          /* 滚动条轨道 */
          .item-right::-webkit-scrollbar-track {
            background-color: rgb(245 245 245/ 1);/* 轨道的颜色 */
            border-radius: 6px; /* 轨道的圆角 */
          }

          /* 滚动条滑块 */
          .item-right::-webkit-scrollbar-thumb {
            background: #c5c5c5; /* 滑块的颜色 */
            border-radius: 0.15rem; /* 滑块的圆角 */
          }

          /* 滑块滑过时的样式 */
          .item-right::-webkit-scrollbar-thumb:hover {
            background: #6e6e6e; /* 滑块悬停时的颜色 */
          }
        }

      .item:last-of-type {
        border-bottom: 0;
      }

      }
  }

  @keyframes cut-user {
    0% {
      transform: translateX(0);
      opacity: 1;
    }
    100% {
      transform: translateX(20%);
      opacity: 0;
    }
  }

  @keyframes cut-user-two {
    0% {
      transform: translateX(30%);

    }
    100% {
      transform: translateX(0);
    }
  }

  .cut-login-enter-from, .cut-login-leave-to {
    animation: cut-user .2s;
  }

  .cut-login-enter-active, .cut-login-leave-active {
    animation: cut-user-two .5s;
  }

  @keyframes success-login {
    0% {
      transform: translateX(-30%);
    }
  }

  @keyframes success-login-2 {
    100% {
      transform: translateX(-30%);
    }
  }

  .success-login-enter-active, .success-login-leave-active {
    animation: success-login .2s;
  }

  .success-login-enter-from, .success-login-leave-to {
    animation: success-login-2 .1s;
  }
</style>
